/**
 * 
 */
package com.disys.mb.support;

import java.io.Serializable;
import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

import com.disys.facade.support.Rec202EMPLPIMSupportFacade;
import com.disys.mb.AbstractMB;
import com.disys.model.support.Rec202EMPLPIMSupport;

/**
 * @author Ubaid Raja
 *
 */
@ViewScoped
@ManagedBean(name="rec202EMPLPIMSupportMB")
public class Rec202EMPLPIMSupportMB extends AbstractMB implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = -4002698515072803607L;
	private Rec202EMPLPIMSupportFacade facade;
	private List<Rec202EMPLPIMSupport> list;
	private Rec202EMPLPIMSupport obj;
	
	private String cocode;
	private String inhousenum;
	private String direct_login;
	private String eestatcd;
	private String twn_add;
	private String ucx_add;
	private String add_ind_1;
	private String type_1;
	
	public Rec202EMPLPIMSupportMB(){
		facade = new Rec202EMPLPIMSupportFacade();
		obj = getObj();
		setCocode(obj.getCocode());
		setInhousenum(obj.getInhousenum());
		setDirect_login(obj.getDirect_login());
		setEestatcd(obj.getEestatcd());
		setTwn_add(obj.getTwn_add());
		setUcx_add(obj.getUcx_add());
		setAdd_ind_1(obj.getAdd_ind_1());
		setType_1(obj.getType_1());
	}
	/**
	 * @return the facade
	 */
	public Rec202EMPLPIMSupportFacade getFacade() {
		if(facade == null){
			return new Rec202EMPLPIMSupportFacade();
		}
		return facade;
	}
	
	public String update(){
		Rec202EMPLPIMSupport object = new Rec202EMPLPIMSupport();
		object.setAdd_ind_1(add_ind_1);
		object.setCocode(cocode);
		object.setDirect_login(direct_login);
		object.setEestatcd(eestatcd);
		object.setInhousenum(inhousenum);
		object.setTwn_add(twn_add);
		object.setType_1(type_1);
		object.setUcx_add(ucx_add);
		object.setId(obj.getId());
		try{
			facade.update(object);
			displayInfoMessageToUser("Record updated successfully!!!");
			return null;
		}catch(Exception e){
			displayErrorMessageToUser("Error updating record !!!");
			return null;
		}
	}
	
	public void cancel(){
		System.out.println("Cancel");
	}
	/**
	 * @return the list
	 */
	public List<Rec202EMPLPIMSupport> getList() {
		return facade.findAllRecords();
	}

	/**
	 * @param list the list to set
	 */
	public void setList(List<Rec202EMPLPIMSupport> list) {
		this.list = list;
	}

	/**
	 * @return the obj
	 */
	public Rec202EMPLPIMSupport getObj() {
		
		Rec202EMPLPIMSupport entity = getFacade().findSingleRecord();
		if(entity == null){
			entity = new Rec202EMPLPIMSupport();
		}
		return entity;
	}

	/**
	 * @param obj the obj to set
	 */
	public void setObj(Rec202EMPLPIMSupport obj) {
		this.obj = obj;
	}


	/**
	 * @return the cocode
	 */
	public String getCocode() {
		return cocode;
	}


	/**
	 * @param cocode the cocode to set
	 */
	public void setCocode(String cocode) {
		this.cocode = cocode;
	}


	/**
	 * @return the inhousenum
	 */
	public String getInhousenum() {
		return inhousenum;
	}


	/**
	 * @param inhousenum the inhousenum to set
	 */
	public void setInhousenum(String inhousenum) {
		this.inhousenum = inhousenum;
	}


	/**
	 * @return the direct_login
	 */
	public String getDirect_login() {
		return direct_login;
	}


	/**
	 * @param direct_login the direct_login to set
	 */
	public void setDirect_login(String direct_login) {
		this.direct_login = direct_login;
	}


	/**
	 * @return the eestatcd
	 */
	public String getEestatcd() {
		return eestatcd;
	}


	/**
	 * @param eestatcd the eestatcd to set
	 */
	public void setEestatcd(String eestatcd) {
		this.eestatcd = eestatcd;
	}


	/**
	 * @return the twn_add
	 */
	public String getTwn_add() {
		return twn_add;
	}


	/**
	 * @param twn_add the twn_add to set
	 */
	public void setTwn_add(String twn_add) {
		this.twn_add = twn_add;
	}


	/**
	 * @return the ucx_add
	 */
	public String getUcx_add() {
		return ucx_add;
	}


	/**
	 * @param ucx_add the ucx_add to set
	 */
	public void setUcx_add(String ucx_add) {
		this.ucx_add = ucx_add;
	}


	/**
	 * @return the add_ind_1
	 */
	public String getAdd_ind_1() {
		return add_ind_1;
	}


	/**
	 * @param add_ind_1 the add_ind_1 to set
	 */
	public void setAdd_ind_1(String add_ind_1) {
		this.add_ind_1 = add_ind_1;
	}


	/**
	 * @return the type_1
	 */
	public String getType_1() {
		return type_1;
	}


	/**
	 * @param type_1 the type_1 to set
	 */
	public void setType_1(String type_1) {
		this.type_1 = type_1;
	}


	/**
	 * @param facade the facade to set
	 */
	public void setFacade(Rec202EMPLPIMSupportFacade facade) {
		this.facade = facade;
	}
	
}
